/**
 * Created by Coing on 2017/2/26.
 */

import java.util.HashMap;
import java.util.Map;

/**
 * 数据在个数比较少的情况下，可以使用，在数据比较多，感觉map，会不会更好呢。。
 *
 */
public class Solution1 {
    public boolean canConstruct(String ransomNote, String magazine) {
        int[] arr = new int[26];
        for(char c: magazine.toCharArray()){
            arr[c-'a']++;
        }
        for(char c: ransomNote.toCharArray()){
            if(- - arr[c - 'a'] < 0){
                return false;
            }
        }

        return true;
    }

    public static void main(String[] args) {
            Solution1 solution = new Solution1();
            System.out.println(solution.canConstruct("a", "b"));
            System.out.println(solution.canConstruct("aa", "ab"));
            System.out.println(solution.canConstruct("aa", "aab"));

    }


}
